<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <div class="panel-lead"><em>Banner图（Banner Image）</em>用于管理首页Banner图数据，启用英文后切换English管理英文数据</div>
        {if $switch_lang == '1'}
        <ul class="nav nav-tabs" data-field="lang">
            {foreach name="langList" item="vo"}
            <li class="{:$Think.get.lang === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab" onclick="updateBoxStyle('{$key}')">{$vo}</a></li>
            {/foreach}
        </ul>
        {/if}
    </div>
    <div {if $switch_lang == '1'}class="box" id="SwitchColors"{/if}>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('wwh/banner/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('wwh/banner/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('wwh/banner/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                           data-operate-edit="{:$auth->check('wwh/banner/edit')}" 
                           data-operate-del="{:$auth->check('wwh/banner/del')}" 
                           width="100%">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

</div>

<script>
    // 直接定义全局函数
    function updateBoxStyle(langId) {
        // 样式映射
        const styleMap = {
            '1': 'box-success',
            '2': 'box-warning'
        };

        // 清除旧样式
        document.getElementById('SwitchColors').classList.remove('box-success', 'box-warning');

        // 添加新样式
        document.getElementById('SwitchColors').classList.add(styleMap[langId] || 'box-success');

        console.log('当前语言:', langId, '应用样式:', styleMap[langId]);
    }

    // 初始化执行
    document.addEventListener('DOMContentLoaded', function() {
        // 获取当前激活的Tab
        const activeTab = document.querySelector('#lang-tabs li.active a');
        if (activeTab) {
            updateBoxStyle(activeTab.dataset.lang);
        }
    });
</script>
